package com.qidianit.mes.pro.controller;

import com.qidianit.mes.common.Result;
import com.qidianit.mes.pojo.pro.ProductionOrder;
import com.qidianit.mes.pro.mapper.ProductionOrderMapper;
import com.qidianit.mes.pro.service.ProductionOrderService;
import com.qidianit.mes.vo.ProductionOrderPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Package Path: com.qidianit.mes.pro.controller
 * Author: Alhz
 * Description:
 * Date: 2025/9/21 18:36
 */
@RestController
@RequestMapping("/productionOrder")
public class ProductionOrderController {
    @Autowired
    private ProductionOrderService productionOrderService;

    @GetMapping("/list")
    public Result selectAllOrder(ProductionOrderPageVo productionOrderPageVo,
                                 @RequestParam(defaultValue = "1") int page,
                                 @RequestParam(defaultValue = "10") int pageSize){
        return productionOrderService.selectAllOrders(productionOrderPageVo,page,pageSize);
    }
    
    @PostMapping("/add")
    public Result addProductionOrder(@RequestBody ProductionOrder productionOrder){
        return productionOrderService.addProductionOrder(productionOrder);
    }

    @PutMapping("/update")
    public Result updateProductionOrder(@RequestBody ProductionOrder productionOrder){
        return productionOrderService.updateProductionOrder(productionOrder);
    }
    
    @GetMapping("/{id}")
    public Result getProductionOrderById(@PathVariable Long id){
        return productionOrderService.getProductionOrderById(id);
    }

    @DeleteMapping("/delete/{id}")
    public Result deleteProductionOrderById(@PathVariable Long id){
        return productionOrderService.deleteProductionOrderById(id);
    }

    @PutMapping("/{id}")
    public Result updateStatus(@PathVariable Long id,@RequestParam Integer status){
        return productionOrderService.updateProductionOrderStatus(id,status);
    }



    
}
